Exampels of Widget-based Applications¶
R. Xue - Last update: July 10, 2020
This is markdown¶
[1]:
!jupyter labextension list
!pip show bqplot ipyvolume pythreejs
JupyterLab v2.1.5
Known labextensions:
app dir: /opt/local/Library/Frameworks/Python.framework/Versions/3.8/share/jupyter/lab
@jupyter-widgets/jupyterlab-manager v2.0.0 enabled OK
bqplot v0.5.14 enabled OK
ipyvolume v0.6.0-alpha.5 enabled OK
jupyter-leaflet v0.13.1 enabled OK
jupyter-matplotlib v0.7.2 enabled OK
jupyter-threejs v2.2.0 enabled OK
Name: bqplot
Version: 0.12.14
Summary: Interactive plotting for the Jupyter notebook, using d3.js and ipywidgets.
Home-page: https://github.com/bloomberg/bqplot
Author: The BQplot Development Team
Author-email: UNKNOWN
License: Apache
Location: /Users/Rui/Library/Python/3.8/lib/python/site-packages
Requires: traitlets, pandas, traittypes, numpy, ipywidgets
Required-by: ipyvolume, bqplot-image-gl
---
Name: ipyvolume
Version: 0.6.0a6
Summary: IPython widget for rendering 3d volumes
Home-page: https://github.com/maartenbreddels/ipyvolume
Author: Maarten A. Breddels
Author-email: maartenbreddels@gmail.com
License: MIT
Location: /Users/Rui/Library/Python/3.8/lib/python/site-packages
Requires: traitlets, traittypes, Pillow, ipywidgets, numpy, pythreejs, ipywebrtc, requests, matplotlib, bqplot
Required-by:
---
Name: pythreejs
Version: 2.2.0
Summary: Interactive 3d graphics for the Jupyter notebook, using Three.js from Jupyter interactive widgets.
Home-page: https://github.com/jupyter-widgets/pythreejs
Author: PyThreejs Development Team
Author-email: jason@jasongrout.org
License: BSD
Location: /Users/Rui/Library/Python/3.8/lib/python/site-packages
Requires: ipydatawidgets, ipywidgets, numpy
Required-by: ipyvolume
[2]:
import ipywidgets
ipywidgets.FloatSlider()
[3]:
#!pip install --user ipyleaflet
from ipyleaflet import Map
Map(center=[41.6611277,-91.5301683], zoom=15)
[4]:
#!pip install --user bqplot
#!jupyter labextension install bqplot
import numpy as np
import bqplot.pyplot as plt
size = 100
plt.figure(title='Scatter plot with colors')
plt.scatter(np.random.randn(size), np.random.randn(size), color=np.random.randn(size))
plt.show()
[5]:
from pythreejs import *
import numpy as np
from IPython.display import display
from ipywidgets import HTML, Text, Output, VBox
from traitlets import link, dlink
ball = Mesh(geometry=SphereGeometry(radius=1, widthSegments=32, heightSegments=24),
material=MeshLambertMaterial(color='red'),
position=[2, 1, 0])
c = PerspectiveCamera(position=[0, 5, 5], up=[0, 1, 0],
children=[DirectionalLight(color='white', position=[3, 5, 1], intensity=0.5)])
scene = Scene(children=[ball, c, AmbientLight(color='#777777')])
renderer = Renderer(camera=c,
scene=scene,
controls=[OrbitControls(controlling=c)])
display(renderer)
[6]:
import ipyvolume as ipv
import numpy as np
N = 1000
x, y, z = np.random.normal(0, 1, (3, N))
fig = ipv.figure()
scatter = ipv.scatter(x, y, z)
ipv.show()
V = np.random.random((128,128,128)) # our 3d array
ipv.quickvolshow(V)
[7]:
#%matplotlib inline
%matplotlib widget
import matplotlib.pyplot as plt
plt.figure()
plt.plot([1,2,3])
[7]:
[<matplotlib.lines.Line2D at 0x148bab760>]
[ ]: